package com.timothy.junk.adapter;

import android.content.Context;
import android.content.SharedPreferences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import java.util.HashMap;
import java.util.List;
import com.timothy.junk.R;
import com.timothy.gfund.bean.RepoSetting;

public class RepoSettingAdaptor extends BaseAdapter {
	private Context 					mContext;
	private List<RepoSetting> 			listItems;
	private LayoutInflater 				mInflater;
	private SharedPreferences sp;

	HashMap<Integer,View> viewMap = new HashMap<Integer,View>();

	static class ViewHolder{
	        public TextView sIndex;
	        public TextView sCode;
		    public TextView sName;
//		    public TextView price;
		    public TextView sCeil;
	 }

	public RepoSettingAdaptor(Context context, List<RepoSetting> data,SharedPreferences sp) {
		this.mContext = context;
		mInflater = LayoutInflater.from(context); 
		this.listItems = data;
		this.sp = sp;
	}

	
	@Override
	public int getCount() {
		return listItems.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;  
        if (convertView == null){  
            holder = new ViewHolder();  
            convertView = mInflater.inflate(R.layout.repo_setting_list_item, null);
            
			holder.sIndex = (TextView) convertView.findViewById(R.id.sIndex);
			holder.sCode = (TextView) convertView.findViewById(R.id.sCode);
			holder.sName = (TextView) convertView.findViewById(R.id.sName);
//			holder.price = (TextView) convertView.findViewById(R.id.price);
			holder.sCeil = (TextView) convertView.findViewById(R.id.sCeil);

            convertView.setTag(holder);  
        }else {  
            holder = (ViewHolder) convertView.getTag();  
        }

        RepoSetting sRepo = listItems.get(position);
        
		holder.sIndex.setText(String.valueOf(sRepo.getIndex()));
		holder.sCode.setText(sRepo.getCode());
		holder.sName.setText(sRepo.getName());
//		holder.price.setText(StringUtil.formatData2Deci(repo.getPrice())+"%");
		holder.sCeil.setText(String.valueOf(sRepo.getCeilRepo()));
		
        return convertView; 
        
	}

}
